package models

import (
	"time"
)

// OrderPayment 订单支付记录表
type OrderPayment struct {
	ID                uint64     `gorm:"primaryKey;autoIncrement;comment:主键ID" json:"id"`
	PaymentNo         string     `gorm:"type:varchar(32);uniqueIndex;not null;comment:支付单号" json:"payment_no"`
	OrderID           uint64     `gorm:"not null;index;comment:订单ID" json:"order_id"`
	PaymentType       int8       `gorm:"type:tinyint;not null;index;comment:支付类型(1-租金,2-押金,3-服务费,4-水电费,5-违约金,6-退款)" json:"payment_type"`
	PaymentMethod     int8       `gorm:"type:tinyint;not null;comment:支付方式(1-支付宝,2-微信,3-银行卡,4-现金,5-其他)" json:"payment_method"`
	PaymentChannel    int8       `gorm:"type:tinyint;not null;comment:支付渠道(1-微信,2-支付宝,3-银行卡,4-现金,5-其他)" json:"payment_channel"`
	Amount            float64    `gorm:"type:decimal(10,2);not null;comment:金额" json:"amount"`
	PaymentStatus     int8       `gorm:"type:tinyint;default:0;index;comment:支付状态(0-待支付,1-支付成功,2-支付失败,3-已退款,4-已取消)" json:"payment_status"`
	TransactionID     string     `gorm:"type:varchar(100);index;comment:第三方支付单号" json:"transaction_id"`
	ThirdPartyOrderNo string     `gorm:"type:varchar(100);comment:第三方订单号" json:"third_party_order_no"`
	PaidAt            *time.Time `gorm:"type:timestamp;index;comment:支付时间" json:"paid_at"`
	RefundAt          *time.Time `gorm:"type:timestamp;comment:退款时间" json:"refund_at"`
	FailureReason     string     `gorm:"type:varchar(500);comment:失败原因" json:"failure_reason"`
	Remark            string     `gorm:"type:varchar(500);comment:备注" json:"remark"`
	CreatedAt         time.Time  `gorm:"autoCreateTime;comment:创建时间" json:"created_at"`
	UpdatedAt         time.Time  `gorm:"autoUpdateTime;comment:更新时间" json:"updated_at"`
}
